﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Entities;
using Logic;

namespace thi5lb
{
    public partial class Menu : Form
    {
        public Menu()
        {
            InitializeComponent();
        }
        public Division Div = new Division();

        public Menu(Division G)
        {
            InitializeComponent();
            Div = G;
        }

        private void Print()
        {
            for (int i = 0; i < Div.Flowers.Count; i++)
            {
                String s = Div.Flowers[i].GetType().ToString();
                switch (s)
                {
                    case "Entities.Astra":
                        listBox1.Items.Add(((Astra)Div.Flowers[i]).Name + " - " + ((Astra)Div.Flowers[i]).Price);
                        break;
                    case "Entities.Cactus":
                        listBox1.Items.Add(((Cactus)Div.Flowers[i]).Name + " - " + ((Cactus)Div.Flowers[i]).Price);
                        break;
                    case "Entities.Geran":
                        listBox1.Items.Add(((Geran)Div.Flowers[i]).Name + " - " + ((Geran)Div.Flowers[i]).Price);
                        break;
                    case "Entities.Home":
                        listBox1.Items.Add(((Home)Div.Flowers[i]).Name + " - " + ((Home)Div.Flowers[i]).Price);
                        break;
                    case "Entities.Outdoor":
                        listBox1.Items.Add(((Outdoor)Div.Flowers[i]).Name + " - " + ((Outdoor)Div.Flowers[i]).Price);
                        break;
                    case "Entities.Rose":
                        listBox1.Items.Add(((Rose)Div.Flowers[i]).Name + " - " + ((Rose)Div.Flowers[i]).Price);
                        break;
                }
            }
        }
        private void Menu_Load(object sender, EventArgs e)
        {
            Print();
        }

        private void button1_Click_1(object sender, EventArgs e)
        {


            New_fl Nf = new New_fl();

            Nf.ShowDialog();

            Division Ad = Nf.div;

            for (int i = 0; i < Ad.Flowers.Count; i++)
            {
                if (this.listBox1.SelectedItem == null)
                {

                    String s = Ad.Flowers[i].GetType().ToString();
                    switch (s)
                    {
                        case "Entities.Astra":
                            Div.Add((Astra)Ad.Flowers[i]);
                            break;
                        case "Entities.Cactus":
                            Div.Add((Cactus)Ad.Flowers[i]);
                            break;
                        case "Entities.Geran":
                            Div.Add((Geran)Ad.Flowers[i]);
                            break;
                        case "Entities.Home":
                            Div.Add((Home)Ad.Flowers[i]);
                            break;
                        case "Entities.Outdoor":
                            Div.Add((Outdoor)Ad.Flowers[i]);
                            break;
                        case "Entities.Rose":
                            Div.Add((Rose)Ad.Flowers[i]);
                            break;

                    }
                }

            }

            listBox1.Items.Clear();

            Print();
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            int temp = listBox1.SelectedIndex;
            listBox1.Items.RemoveAt(temp);
            Div.Flowers.RemoveAt(temp);
        }

        private void button3_Click_1(object sender, EventArgs e)
        {
            label1.Text = FlowerCalculator.CalculatePrice(Div).ToString();
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click_1(object sender, EventArgs e)
        {

        }
    }
}
